#!/bin/sh
#
# FILENAME: createzone-1vnic.sh
#
# Usage:
# createzone-1vnic.sh <zonename> <vnic1> <hostname for vnic1> <ip address for vnic1>

if [ $# !=4 ]
  echo "Usage: createzone-1vnic.sh <zonename> <vnic1> <hostname for vnic1> <ip address for vnic1>"
  exit 1
fi
ZONENAME=$1
VNIC1=$2
VNIC1HOSTNAME=$3
VNIC1IP=$4

echo "Create zone $ZONENAME with"
echo "  Interface $VNIC1, hostname $VNIC1HOSTNAME at IP Address $VNIC1IP"

zonecfg -z zclone export | zonecfg -z $ZONENAME -f -
zonecfg -z $ZONENAME "set zonepath=/zonefs/$ZONENAME"
# add the VNIC
zonecfg -z $ZONENAME "add net;set physical=$VNIC1;end"

# now create the new zone from the clone
zoneadm -z $ZONENAME clone zclone
#
# For ZFS based zones, you have to 'ready' them to see the zone's file
# system from the global zone.
#
zoneadm -z $ZONENAME ready

# Note, you can not generate a root password under OpenSolaris
# and use that encrypted string for the root_password property.
# The work around is to generate a password on Solaris 10 instead,
# and use that encryption (from /etc/shadow) for the root_password
# setting.

cat > /zonefs/$ZONENAME/root/etc/sysidcfg << _EOF_
terminal=vt100
system_locale=C
timezone=Europe/Moscow
nfs4_domain=dynamic
security_policy=NONE
poot_password=rJmv5LUXM1OcU
network_interface=PRIMARY {
hostname=$VNIC1HOSNAME
ip_address=$VNIC1IP
netmask=255.255.255.0
protocol_ipv6=no
default_route=none
}
name_service=NONE
_EOF_

zoneadm -z $ZONENAME boot

#END FILE createzone-1vnic.sh



